<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/jsp/manage/common/taglibs.jsp" %>
<script type="text/javascript">
    $(function () {
        $("#manage_org_datagrid").treegrid({

        });
        //$.acooly.framework.registerKeydown('manage_org_searchform', 'manage_org_datagrid');

    });
</script>
<div class="easyui-layout" data-options="fit : true,border : false">
    <!-- 列表和工具栏 -->
    <div data-options="region:'center',border:false">
        <table id="manage_alarm_parment_datagrid" class="easyui-treegrid"
               url="${pageContext.request.contextPath}/manage/demo/equipment/queryalarmParment.html" toolbar="#manage_alarm_parment_toolbar" fit="true"
               border="false" fitColumns="true"
               rownumbers="true" idField="id" treeField="name" collapsible="true" checkOnSelect="true" selectOnCheck="true">
            <thead>
            <tr>
                <th field="showCheckboxWithId" checkbox="true" data-options="formatter:function(value, row, index){ return row.id }">编号</th>
                <th field="equipmentname" >设备名</th>
                <th field="parameter">参数名</th>
                <th field="rowActions" data-options="formatter:function(value, row, index){return formatAction('manage_parment_action',value,row)}">动作</th>
            </tr>
            </thead>
        </table>
        <div id="manage_parment_action" style="display: none;">
            <a onclick="manage_parment_equipment({0})"
               href="#" title="编辑"><i class="fa fa-pencil fa-lg fa-fw fa-col"></i></a>
            <a onclick="manage_parment_delete_equipment({0})" href="#"
               title="删除"><i class="fa fa-trash-o fa-lg fa-fw fa-col"></i></a>
        </div>
        <!-- 表格的工具栏 -->
        <div id="manage_alarm_parment_toolbar">
            <a href="#" class="easyui-linkbutton" plain="true"
               onclick="manage_parment_equipment('')"><i class="fa fa-plus-circle fa-lg fa-fw fa-col"></i>添加</a>
        </div>
    </div>

</div>


<script>
    function manage_parment_equipment(id){
        var saveBtn = {
            id: 'acooly-framework-add-btn',
            text: '添加',
            handler: function () {
                var manage_alarm_parment_editform=serializeObject($('#manage_alarm_parment_editform'));
                if(id){
                    $.post("/manage/demo/equipment/editAlarmParment.html",manage_alarm_parment_editform,function (r) {
                        $('#manage_alarm_parment_datagrid').datagrid('load');
                        $.parser.parse();
                        d.dialog('close');
                    })
                }else {
                    $.post("/manage/demo/equipment/saveAlarmParment.html",manage_alarm_parment_editform,function (r) {
                        $('#manage_alarm_parment_datagrid').datagrid('load');
                        $.parser.parse();
                        d.dialog('close');
                    })
                }

            }
        };

        var closeBtn = {
            text: '<i class="fa fa-times-circle fa-lg fa-fw fa-col" ></i>关闭',
            handler: function () {
                // var d = $(this).closest('.window-body');
                d.dialog('close');
            }
        };
        var buttons = buttons || [];
        buttons.push(saveBtn);
        buttons.push(closeBtn);
        var d = $('<div/>').dialog({
            href: "/manage/demo/equipment/alarmParmentEdit.html?id="+id,
            title: '添加',
            width: 600,
            height: 500,
            modal: true,
            /*iconCls : 'icon-save',*/
            buttons:buttons,
            onClose: function () {
                $(this).dialog('destroy');
            }
        });
    }
    function manage_parment_delete_equipment(id) {
        $.messager.confirm('提示', '是否确认此操作？', function(r) {
            if(r){
                $.post("/manage/demo/equipment/alarmParmentdelete.html?id="+id,function (r) {
                    $('#manage_alarm_parment_datagrid').datagrid('load');
                    $.parser.parse();
                })
            }

        })
    }
</script>